<?php
require(dirname(__FILE__) . '/includes/init.php');
if($_REQUEST['act'] == 'view'){	
	$addtime = $_REQUEST['addtime'];
	$sql="select products_sn,start from ".$ecs->table('yihaodian')." where add_time='".$addtime."'";
	$sn_list = $db->getAll($sql);
	$change_list = array();
	foreach($sn_list as $sn){
		$sku = $sn['products_sn'];
		$start = $sn['start'];
		$sql = "select * from ".$ecs->table('yihaodian')." where products_sn='".$sku."' and start='".($start)."'";
		$goods1 = $db->getRow($sql);
		$sql = "select * from ".$ecs->table('yihaodian')." where products_sn='".$sku."' and start='".($start-1)."'";
		$goods2 = $db->getRow($sql);
		if($goods1['ranking']-$goods2['ranking']!=0){
			$cha = $goods1['ranking']-$goods2['ranking'];
			if($cha>0){
				$goods1['change']='↓'.$cha;
			}else if($cha<0){
				$goods1['change']='↑'.abs($cha);
			}
			array_push($change_list,$goods1);
		}
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理中心 - 排名变化 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
 
<h1>
<span class="action-span1"><a target="_top" href="index.php?act=main">管理中心</a> </span><span id="search_id" class="action-span1"> - 排名变化 </span>
<div style="clear:both"></div>
</h1>
  <div class="list-div" id="listDiv">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>SKU</th>
	<th>商品名</th>
	<th>商家名</th>
	<th>排名</th>
	<th>价格</th>
	<th>评价总数</th>
    <th>历史排名</th>
  <tr>
  <?php 
	if(count($change_list)>0){
	foreach($change_list AS $index => $array_val){
  ?>
   <tr <?php if($array_val['provider']=='悦国酒类专营店'){echo 'style="color:red"';}else{echo '';}?>>
    <td><?php echo $array_val['products_sn'];?></td>
	<td><a href="http://www.yihaodian.com/product/<?php echo $array_val['products_sn'];?>" target="_blank"><?php echo $array_val['products_name'];?></a></td>
    <td><?php echo $array_val['provider'];?></td>
	<td><?php echo $array_val['ranking'];?>
	<span style="color:red">
	<?php echo $array_val['change'];?></span></td>
	<td><?php echo $array_val['price'];?></td>
    <td><?php echo $array_val['commentcount'];?></td>
	<td><a href="yihaodian_d.php?act=search&products_sn=<?php echo $array_val['products_sn'];?>">查看</a></td>
  <tr>
  <?php 
      } 
	}
  ?>
  </table>
 
<!-- 分页 -->
  </div>
  </body>
</html>